package com.shujia.wyh.day21;

public class Student4 implements Comparable<Student4> {
    private String name;
    private int age;

    public Student4() {
    }

    public Student4(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student4{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student4 o) {
        int i = this.name.compareTo(o.name);
        //姓名一样，年龄不一定一样
        int i2 = (i == 0) ? this.age - o.age : i;
        return i2;
    }
}
